package com.exchange.used.config.converters;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.converter.AbstractHttpMessageConverter;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;

import java.io.IOException;

public class BackResultConverter extends AbstractHttpMessageConverter<BackResult> {


    @Override
    protected boolean supports(Class<?> clazz) {
        return clazz.equals(BackResult.class);
    }

    @Override
    protected BackResult readInternal(Class<? extends BackResult> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
        return null;
    }

    @Override
    protected void writeInternal(BackResult backResult, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
        outputMessage.getBody().write(backResult.toString().getBytes());
    }
}
